package com.bdqn.crm.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bdqn.crm.pojo.Pagee;
import com.bdqn.crm.pojo.Storage;
import com.bdqn.crm.service.StorageService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller
public class StorageContorller {
    @Resource
    private StorageService storageService;

    @RequestMapping(value = "storage/list")
    public String storage(Model model, @RequestParam(value = "prodName",required = false) String prodName,
                          @RequestParam(value = "stkWarehouse",required = false)String stkWarehouse, Long pageIndex){
        //数据回显
        model.addAttribute("prodName",prodName);
        model.addAttribute("stkWarehouse",stkWarehouse);
        //如果为空，查询第一页
        if(pageIndex == null){
            pageIndex = 1L;
        }
        Page<Storage> page = new Page<>();
        page.setCurrent(pageIndex);
        IPage<Storage> storageIPage = storageService.page(prodName,stkWarehouse,page);
        model.addAttribute("storagePage",storageIPage);

//        Pagee<Storage> pagee = storageService.pagee(prodName,stkWarehouse,pageIndex);
//        model.addAttribute("storagePage",pagee);
        return "storage/list";
    }
}
